﻿package com.truongnha.clienttn.presentation;

import com.truongnha.clienttn.R;
import com.truongnha.clienttn.business.model.UserModel;
import com.truongnha.clienttn.business.service.ProfileService;

import android.os.Bundle;
import android.app.ListActivity;
import android.view.Menu;
import android.widget.ArrayAdapter;

public class ProfileActivity extends ListActivity {
	private UserModel user;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.profile);

		ProfileService profileService = new ProfileService(
				getApplicationContext());
		user = profileService.getUser();
		String[] userDetails = new String[] { "type: ",
				"Trường: " + user.getSchool(),
				"Họ và tên: " + user.getLastName() + " " + user.getFirstName(),
				"Lớp: " + user.get_class(), "Ngày sinh: " + user.getBirthday() };

		if (user.getPosition().equals("TEACHER")) { // 3 <=> teacher
			userDetails[0] = "Tài khoản giáo viên";
		} else { // 1<=> student
			userDetails[0] = "Tài khoản học sinh";
		}
		setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item,
				userDetails));

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
